<?php
require 'header.php';
require 'DAO.php';

$name = $_POST['name'];
$password = $_POST['password'];

if (!isset($_SESSION['attempts']))
    $_SESSION['attempts'] = 0;
$attempts = $_SESSION['attempts'];

if (!isset($name) || !isset($password)) {

?>
<style>
	@font-face {
		font-family: russischFont;
		src: url('uploads/DINARJEVREPUBLIKA_0.TTF');
	}

	h1 {
		font-family: russischFont;
		font-size: 20px;
		color: green;
		padding: 0;
	}

	img {
		margin-left: 20px;
	}

	input {
		position: relative;
		border: solid 1px #c9c9c9;
		font-family: "Myriad Pro", "Verdana";
		resize: none;
		outline: none;
		overflow: visible;
		padding: 3px;
		box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.30) inset;
		-moz-box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.30) inset;
		-webkit-box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.30) inset;
	}

	#login {
		border: solid 1px #c9c9c9;
		border-bottom: none;
		font-family: "Myriad Pro", "Verdana";
		background-color: rgba(220, 220, 220, 0.4);
		box-shadow: 0px 1px 8px rgba(0, 0, 0, 0.90);
		-moz-box-shadow: 0px 1px 8px rgba(0, 0, 0, 0.90);
		-webkit-box-shadow: 0px 1px 8px rgba(0, 0, 0, 0.90);
		width: 300px;
		margin: auto;
		margin-top: 100px;
		padding: 10px;
		padding-bottom: 0px;
	}

	#knop {
		border: solid 2px green;
		font-family: russischFont;
		font-size: 20px;
		color: white;
		left: 200px;
		bottom: 72px;
		width: 70px;
		height: 70px;
		border-radius: 6px;
		background-image: linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -o-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -moz-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -webkit-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -ms-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		box-shadow: -3px -3px 8px rgba(0, 0, 0, 0.30) inset;
		-moz-box-shadow: -3px -3px 8px rgba(0, 0, 0, 0.30) inset;
		-webkit-box-shadow: -3px -3px 8px rgba(0, 0, 0, 0.30) inset;
	}

	#knop:hover {
		border: solid 2px green;
		font-family: russischFont;
		font-size: 20px;
		color: white;
		left: 200px;
		bottom: 70px;
		width: 70px;
		height: 70px;
		border-radius: 6px;
		background-image: linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -o-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -moz-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -webkit-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		background-image: -ms-linear-gradient(bottom, rgb(28,189,0) 7%, rgb(26,128,10) 52%);
		box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.30) inset;
		-moz-box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.30) inset;
		-webkit-box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.30) inset;
	}
	#forgot {
		color: blue;
		text-decoration: underline;
		font-size: 11px;
	}

</style>

<div id="login">
	<h1>Inloggen of opdonderen</h1>
	<form method="POST" action="login.php">
		Naam:
		<br />
		<input type="text" name="name" />
		<br />
		Wachtwoord:
		<br />
		<input type="password" name="password" />
		<br />
		<input id="knop" type="submit" name="submit" value="meer" />

		<div id="forgot" onclick="window.alert('das kut voor je!');">Wachtwoord vergeten?</div>
	</form>
	<img src="uploads/hardcore_motherfuckers.png" />
</div>
<?php
} else {
$con = new connection();
$authorize = $con->authorize($name, $password);
if ($authorize != -1) {
$_SESSION['clearance'] = $authorize;
$_SESSION['name'] = $name;
header('Location: index.php');
} else {
$_SESSION['attempts'] += 1;
header('Location: login.php');
exit;
}
}
?>